'use strict'

class user {

  constructor (mdb) {
    this.db = mdb
    this.tableName = 'like'
  }

  model () {
    return this.db.model(this.tableName)
  }

  makeId () {
    return `u_${Date.now().toString(16)}${parseInt(Math.random()*10000) + 11111}`
  }

  async get (userid,sayid) {
    let ulist = await this.model().where({userid,sayid}).select()
    return ulist.rows
  }

  async update(data,id){
    await this.model().where({id}).update(data);
  }

  async insert(data){
    data.id=this.makeId()
    await this.model().insert(data)
  }

}

module.exports = user
